package com.example.androidstart.opengl.render;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.opengl.GLSurfaceView;

import com.example.androidstart.filter.AFilter;
import com.example.androidstart.filter.GrayFilter;
import com.example.androidstart.util.Gl2Utils;

import java.nio.ByteBuffer;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

public class FBORender implements GLSurfaceView.Renderer {
    private AFilter mFilter;
    private Bitmap mBitmap;
    private ByteBuffer mBuffer;

    private int[] fFrame = new int[1];
    private int[] fRender = new int[1];
    private int[] fTexture = new int[2];

    private Callback mCallback;

    
    public FBORender(Resources res) {
        mFilter = new GrayFilter(res);
    }

    public void setCallback(Callback callback) {
        this.mCallback = callback;
    }

    public void setBitmap(Bitmap bitmap) {
        this.mBitmap = bitmap;
    }


    @Override
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        mFilter.create();
        mFilter.setMatrix(Gl2Utils.flip(Gl2Utils.getOriginalMatrix(),false,true));
    }

    @Override
    public void onSurfaceChanged(GL10 gl, int width, int height) {

    }

    @Override
    public void onDrawFrame(GL10 gl) {

    }


    interface Callback {
        void onCall(ByteBuffer data);
    }

}
